package com.cloudfast.platform.menu.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.cloudfast.entity.BaseEntity;
import com.cloudfast.repository.annotation.DeleteField;
import com.cloudfast.repository.annotation.SelfGradeCode;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * @author liuyw
 * @描述:
 * @date 2020年4月30日
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "sys_menu")
@Getter
@Setter
@ApiModel(value = "菜单")
public class Menu extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    /**
     * 名称
     */
    @ApiModelProperty(value = "菜单名称", required = true)
    private String name;
    /**
     * path
     */
    @ApiModelProperty(value = "菜单路径", required = true)
    private String path;


    @ApiModelProperty(value = "权限编码", required = true)
    private String checkCode;

    /**
     * 父级
     */
    private Long parentId;

    /**
     * 图标
     */
    @ApiModelProperty(value = "菜单图标", required = true)
    private String icon;

    @ApiModelProperty(value = "类型:对应字典(menu_type)")
    private String type;

    @ApiModelProperty(value = "布局文件")
    private String componentFile;

    @ApiModelProperty(value = "上级布局: system / portal")
    private String permissionScope = "System";

    @ApiModelProperty(value = "路由类型:对应字典router_type")
    private String routerType = "main_route";

    @ApiModelProperty(value = "大屏类型:对应字典screen_type")
    private String screenType;

    @ApiModelProperty(value = "大屏跳转类型:screen_router_type")
    private String screenRouterType;

    /**
     * 级联
     */
    @SelfGradeCode(fileEntity = "gradeCode")
    @Column(name = "grade_code", columnDefinition = " varchar(2550) DEFAULT NULL COMMENT '级联编码'")
    @ApiModelProperty(value = "级联编码", required = false)
    private String gradeCode;

    /**
     * 排序
     */
    @ApiModelProperty(value = "菜单顺序", required = true)
    private int sort;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    /**
     * 是否是顶级菜单
     */
    @ApiModelProperty(value = "是否顶级菜单")
    private String isAdmin = "0";

    /**
     * 删除的状态
     */
    @DeleteField
    @ApiModelProperty(value = "删除字体:默认0")
    private String delFlag = "0";


    public Menu() {

    }

    public Menu(String name, Long parentId, String icon, String type, String componentFile, String permissionScope, int sort) {
        this.name = name;
        this.parentId = parentId;
        this.icon = icon;
        this.type = type;
        this.componentFile = componentFile;
        this.permissionScope = permissionScope;
        this.sort = sort;
    }

    /**
     * 权限
     *
     * @param name
     * @param parentId
     * @param permissionScope
     * @param sort
     */
    public Menu(String name, String checkCode, Long parentId, String permissionScope, int sort) {
        this.name = name;
        this.parentId = parentId;
        this.type = "2";
        this.permissionScope = permissionScope;
        this.sort = sort;
        this.checkCode = checkCode;
    }

    public Menu(String name, Long parentId, String icon, String type, String componentFile, String permissionScope, int sort, String path) {
        this.name = name;
        this.parentId = parentId;
        this.icon = icon;
        this.type = type;
        this.componentFile = componentFile;
        this.permissionScope = permissionScope;
        this.sort = sort;
        this.path = path;
    }

    public Menu(Long id, String name, Long parentId, String icon, String type, String componentFile, String permissionScope, int sort) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.icon = icon;
        this.type = type;
        this.componentFile = componentFile;
        this.permissionScope = permissionScope;
        this.sort = sort;
    }

}
